<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.36">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0000ee}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #7a3827}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #008326}
span.s1 {font: 18.0px Helvetica}
span.s2 {text-decoration: underline}
span.s3 {color: #000000}
span.s4 {color: #214fdb}
span.s5 {color: #1142e6}
span.s6 {color: #0d32ac}
span.s7 {color: #843424}
span.s8 {color: #1337a8}
span.s9 {color: #1b39f5}
span.s10 {color: #132bc3}
span.s11 {color: #737373}
span.s12 {color: #008326}
span.s13 {color: #d5100d}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>RedInfoSms2</b></span><b><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>read scaled raw data from sudden motion sensor</b></p>
<p class="p2"><br></p>
<p class="p1"><b>superclass: RedInfoSms</b></p>
<p class="p2"><br></p>
<p class="p1">Only works on newer portable Mac models running OS X (10.4 or newer).</p>
<p class="p1">Using UniMotion 0.4.1 (http://unimotion.sourceforge.net/) by Lincoln Ramsay</p>
<p class="p2"><br></p>
<p class="p1"><span class="s2">Version 2 notes:</span></p>
<p class="p1">This version reverses the backwards polarity of x and increases the range of the older machines to match the MacBook [Pro] sensor.</p>
<p class="p2"><br></p>
<p class="p3"><span class="s3">see also: <a href="RedInfoSms.html"><span class="s4">RedInfoSms</span></a> <a href="RedInfoSms3.html"><span class="s5">RedInfoSms3</span></a> <a href="RedInfoBat.html"><span class="s2">RedInfoBat</span></a> <a href="RedInfoLmu.html"><span class="s2">RedInfoLmu</span></a></span></p>
<p class="p2"><br></p>
<p class="p1"><b><span class="Apple-tab-span">	</span>*kr(trig)</b></p>
<p class="p1"><b><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b>returns 3 channels.<span class="Apple-converted-space">  </span>x, y and z sensor data (integers).</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>zeros if no sensors installed.</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><b>trig</b> asks for a new reading.<span class="Apple-converted-space">  </span>the faster you ask, the more cpu it will require.</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>note: there is only one reading function internally.<span class="Apple-converted-space">  </span>a trigger will cause global reading for all ugens.</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>it makes little sense to have this ugen running in multiple synths.<span class="Apple-converted-space">  </span>use busses.</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p5">//--</p>
<p class="p6">s.boot;</p>
<p class="p6">{<span class="s6">RedInfoSms2</span>.kr(<span class="s6">Impulse</span>.kr(2)).poll; <span class="s6">DC</span>.ar(0)}.play;<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">//update twice a second</span></p>
<p class="p4"><br></p>
<p class="p5">//very sensitive but will require a bit extra of the cpu</p>
<p class="p6">{<span class="s8">Mix</span>(<span class="s8">SinOsc</span>.ar(<span class="s8">RedInfoSms2</span>.kr(<span class="s8">Impulse</span>.kr(50))+500, 0, 0.4))}.play;</p>
<p class="p4"><br></p>
<p class="p5">//less cpu with lower trig rate and using ramp to smooth data</p>
<p class="p6">{<span class="s8">Mix</span>(<span class="s8">SinOsc</span>.ar(<span class="s8">Ramp</span>.kr(<span class="s8">RedInfoSms2</span>.kr(<span class="s8">Impulse</span>.kr(10)))+500, 0, 0.4))}.play;</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p5">//--gui test</p>
<p class="p6">(</p>
<p class="p7"><span class="s9">var</span> syn, osc;</p>
<p class="p7"><span class="s9">var</span> w= <span class="s10">Window</span>(<span class="s11">"RedInfoSms2 scaled data"</span>, <span class="s10">Rect</span>(100, 200, 300, 120));</p>
<p class="p7"><span class="s9">var</span> c= [-999, 999, <span class="s12">'lin'</span>, 0, 0].asSpec;</p>
<p class="p7"><span class="s9">var</span> x= <span class="s10">EZSlider</span>(w, <span class="s10">Rect</span>(0, 10, 280, 20), <span class="s11">"x"</span>, c);</p>
<p class="p7"><span class="s9">var</span> y= <span class="s10">EZSlider</span>(w, <span class="s10">Rect</span>(0, 40, 280, 20), <span class="s11">"y"</span>, c);</p>
<p class="p7"><span class="s9">var</span> z= <span class="s10">EZSlider</span>(w, <span class="s10">Rect</span>(0, 70, 280, 20), <span class="s11">"z"</span>, c);</p>
<p class="p7">w.view.background= <span class="s10">Color</span>.red(0.75);</p>
<p class="p7">w.front;</p>
<p class="p8"><br></p>
<p class="p9"><span class="s3">syn= </span><span class="s10">SynthDef</span><span class="s3">(</span>\suddenmotionsensor<span class="s3">, {</span><span class="s9">|rate= 15|</span><span class="s3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span><span class="s13">//update rate</span></p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="s9">var</span> trig= <span class="s10">Impulse</span>.kr(rate);</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="s10">SendReply</span>.kr(trig, <span class="s12">'xyz'</span>, <span class="s10">RedInfoSms2</span>.kr(trig));</p>
<p class="p7">}).play(s);</p>
<p class="p7">osc= <span class="s10">OSCresponder</span>(s.addr, <span class="s12">'xyz'</span>, {<span class="s9">|t, resp, m|</span></p>
<p class="p7"><span class="Apple-tab-span">	</span>{</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>x.value= m[3];</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>y.value= m[4];</p>
<p class="p7"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>z.value= m[5];</p>
<p class="p7"><span class="Apple-tab-span">	</span>}.defer;</p>
<p class="p7">}).add;</p>
<p class="p7"><span class="s10">CmdPeriod</span>.doOnce({if(w.isClosed.not, {w.close})});</p>
<p class="p7">w.onClose= {osc.remove; syn.free};</p>
<p class="p6">)</p>
</body>
</html>
